package com.ynny.list01.example01;

import com.ynny.list01.Student;

import java.util.ArrayList;
import java.util.Scanner;

/*
    1.实体类 ------>
    2.跟实体类业务逻辑操作挂钩的服务操作类------->  对实体类 增删改查
    3.程序的主入口类

 */

public class StudentManagerDemo01 {//学生管理案例1

    public static void main(String[] args) {
        //泛型写了之后 才能 确定 集合里面是学生对象
        ArrayList<Student> students = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("请选择1.录入\t0.退出");
            int choice = scanner.nextInt();
            if (choice == 1){
                    System.out.println("请输入学生的姓名");
                    String name = scanner.next();
                    System.out.println("请输入学生的年龄");
                    int age = scanner.nextInt();

                    Student student = new Student();
                    student.setName(name);
                    student.setAge(age);
                    students.add(student);
                    System.out.println(students);

            } else if (choice == 0) {
                for (int i = 0; i < students.size(); i++) {
                    Student stu = students.get(i);
                    System.out.println(stu.getName() + "----" + stu.getAge());
                }
                scanner.close();
                break;
            }
        }

//        for (Student stu : students) {
//
//            System.out.println(stu.getName() + "---" + stu.getAge());
//
//        }




    }
}
